function RegisterAssistant(params) {
	/** this is the creator function for your scene assistant object. It will be passed all the 
	*   additional parameters (after the scene name) that were passed to pushScene. The reference
	*   to the scene controller (this.controller) has not be established yet, so any initialization
	*   that needs the scene controller should be done in the setup function below.
	*/
	  this.userInfo = params;
}

/** this function is for setup tasks that have to happen when the scene is first created 
*/
RegisterAssistant.prototype.setup = function() {
	/** use Mojo.View.render to render view templates and add them to the scene, if needed.
	 */
	
	/** setup widgets here-
	 * Instantiates UI widgets for login scene. Each widget requires attributes and a model.
	 * These are passed to the widget in a JSON object.
	 */
	this.controller.setupWidget("username",
          this.usernameAttributes = {
              hintText: $L('Type your username...'),
              autoFocus: true,
			  preventResize: true,
			  focusMode: Mojo.Widget.focusSelectMode,
			  autoReplace: false,
			  maxLength: 25,
			  textCase: Mojo.Widget.steModeLowerCase
          },
          this.usernameModel = {
              value: this.userInfo.username,
              disabled: false
     });
	 
	 this.controller.setupWidget("password",
          this.passwordAttributes = {
              hintText: $L('Type your password...'),
			  preventResize: true,
			  focusMode: Mojo.Widget.focusSelectMode,
			  maxLength: 100,
          },
          this.passwordModel = {
              value: this.userInfo.password
     });
	 
	 this.controller.setupWidget("confirmpassword",
          this.confirmpasswordAttributes = {
              hintText: $L('Re-type your password...'),
			  preventResize: true,
			  focusMode: Mojo.Widget.focusSelectMode,
			  maxLength: 100,
          },
          this.confirmpasswordModel = {
              value: ""
     });

	this.controller.setupWidget("emailaddress",
          this.emailaddressAttributes = {
              hintText: $L('Type your email address...'),
              autoFocus: false,
			  preventResize: true,
			  focusMode: Mojo.Widget.focusSelectMode,
			  autoReplace: false,
			  maxLength: 50,
			  textCase: Mojo.Widget.steModeLowerCase
          },
          this.emailaddressModel = {
              value: "",
              disabled: false
     });
	 
	 this.controller.setupWidget("submitRegistrationButton",
         this.submitRegistrationButtonAttributes = {
		 	type: Mojo.Widget.activityButton
             },
         this.submitRegistrationButtonModel = {
             label : "Submit Registration",
             disabled: false
    });
	
	
	/** add event handlers to listen to events from widgets
	 */
	this.submitRegistrationButtonHandler = this.submitRegistrationButton.bindAsEventListener(this);
}

/** put in event handlers here that should only be in effect when this scene is active. For
	 * example, key handlers that are observing the document
	 * When the scene is activated, start the event listeners for taps on the
	 * 'Submit Registration' button.
	 */
RegisterAssistant.prototype.activate = function(event) {
	
	  Mojo.Event.listen(this.controller.get('submitRegistrationButton'),Mojo.Event.tap,this.submitRegistrationButtonHandler);
}

/** remove any event handlers you added in activate and do any other cleanup that should happen before
	  * this scene is popped or another scene is pushed on top
	  */
RegisterAssistant.prototype.deactivate = function(event) {
	
	  Mojo.Event.stopListening(this.controller.get('submitRegistrationButton'),Mojo.Event.tap,this.submitRegistrationButtonHandler);
}
/** this function should do any cleanup needed before the scene is destroyed as
	 *  a result of being popped off the scene stack
	 */
RegisterAssistant.prototype.cleanup = function(event) {
	
}

/** This function is called when the submit button is pressed. It will connect to the mySQL
 * database on the BMC Studios LLC. server and register a new user. 
 */
RegisterAssistant.prototype.submitRegistrationButton = function(event) {
	if(!event)
		return;
	var userInfo = {
		'username': this.usernameModel.value,
		'password': this.passwordModel.value,
		'confirmpassword': this.confirmpasswordModel.value,
		'emailaddress': this.emailaddressModel.value
	};
	this.regUser(userInfo);
}

/** This function does a remote server call to a registration script.
 * @param UI User information.
 */
RegisterAssistant.prototype.regUser = function(UI) {    
    var url = "http://www.bmcstudiosllc.com/starmap/" + "mobile_reg.php";

    try{
        var request = new Ajax.Request(url,
        {
            method:'get',
            parameters: {'username': UI.username, 'password': UI.password, 'confirmpassword': UI.confirmpassword, 'emailaddress': UI.emailaddress}, 
            evalJSON:'true',
            onComplete: this.authUserCallback.bind(this),
        });
    }
    catch (e)
    {
        Mojo.log.error(e);
        return 0;
    }
}

/** Callback function for regUser.  It either outputs an error message or if the
 * registration was successful.
 * @param ajaxResponse The response from the remote server call.
 */
RegisterAssistant.prototype.authUserCallback = function(ajaxResponse) {
	this.controller.get('registerButton').mojo.deactivate();
	if (ajaxResponse.responseJSON.returnCode != 1) {
		Mojo.Controller.errorDialog(ajaxResponse.responseJSON.message);
	} else {
		this.controller.stageController.popScene(ajaxResponse.responseJSON);
	}
}